package org.viettan.android.main.activities.common;

import org.viettan.android.main.R;

import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

/**
 * A simple RoboGuice-injectable activity that lists a list of items. This base class automatically
 * adds the "Refresh" context menu items to force-refresh the list.
 */
public abstract class RefreshableListActivity extends VietTanBaseListActivity {

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
	MenuInflater inflater = getMenuInflater();
	inflater.inflate(R.menu.refresh_menu, menu);
	return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
	switch (item.getItemId()) {
	case R.id.refresh:
	    loadList(false);
	    return true;
	default:
	    return super.onOptionsItemSelected(item);
	}
    }

    protected abstract void loadList(boolean useCache);
}
